#include <stdio.h> 
#include <stdlib.h>
#include <unistd.h>    // for pause()
#include <signal.h>    // for signal()
#include <sys/time.h>

void signalHandler(int signo)
{
    if(signo == SIGALRM)
    {
        printf("Caught the SIGALRM signal!\n");
    }
}

int main(int argc, char *argv[])
{
    //char cmd[256];
    signal(SIGALRM, signalHandler);

    struct itimerval new_value, old_value;
    // how long to run the first time
    new_value.it_value.tv_sec = 1;
    new_value.it_value.tv_usec = 0;
    // after the first time, how long to run next time
    new_value.it_interval.tv_sec = 5;
    new_value.it_interval.tv_usec = 0;
    setitimer(ITIMER_REAL, &new_value, &old_value);

    getchar();

    return 0;
}
